//
//  LJTabBarViewController.m
//  百思不得姐
//
//  Created by 刘鹿杰 on 16/7/3.
//  Copyright © 2016年 刘鹿杰. All rights reserved.
//

#import "LJTabBarViewController.h"
#import "LJNavigationViewController.h"
#import "LJEssenceViewController.h"
#import "LJFriendTrendsViewController.h"
#import "LJMeViewController.h"
#import "LJNewViewController.h"
#import "LJTabbar.h"




@interface LJTabBarViewController ()

@end

@implementation LJTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 设置全局属性
    NSMutableDictionary * attrs = [NSMutableDictionary dictionary];
    attrs[NSFontAttributeName] = [UIFont systemFontOfSize:13];
    attrs[NSForegroundColorAttributeName] = [UIColor grayColor];
    
    NSMutableDictionary * selectesAttrs = [NSMutableDictionary dictionary];
    selectesAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:13];
    selectesAttrs[NSForegroundColorAttributeName] = [UIColor darkGrayColor];
    
    UITabBarItem *item = [UITabBarItem appearance];
    [item setTitleTextAttributes:attrs forState:UIControlStateNormal];
    [item setTitleTextAttributes:selectesAttrs forState:UIControlStateSelected];
    
     // 添加控制器
     [self setUpchildVCWithTilte:@"精华" addimageName:@"tabBar_essence_icon" addselelctImageName:@"tabBar_essence_click_icon" addtarget:[[LJEssenceViewController alloc] init]];
    
     [self setUpchildVCWithTilte:@"最新" addimageName:@"tabBar_new_icon" addselelctImageName:@"tabBar_new_click_icon" addtarget:[[LJNewViewController alloc] init]];
    
     [self setUpchildVCWithTilte:@"关注" addimageName:@"tabBar_friendTrends_icon" addselelctImageName:@"tabBar_friendTrends_click_icon" addtarget:[[LJFriendTrendsViewController alloc] init]];
    
     [self setUpchildVCWithTilte:@"我" addimageName:@"tabBar_me_icon" addselelctImageName:@"tabBar_me_click_icon" addtarget:[[LJMeViewController alloc] init]];
    
    
     [self setValue:[[LJTabbar alloc] init] forKey:@"tabBar"];
}


-(void)setUpchildVCWithTilte:(NSString *)titile addimageName:(NSString *) imageName  addselelctImageName:(NSString *)selectImageName addtarget:(UIViewController *)vc{

    vc.tabBarItem.title = titile;
    vc.tabBarItem.image = [UIImage imageNamed:imageName];
    vc.tabBarItem.selectedImage = [UIImage imageNamed:selectImageName];
    LJNavigationViewController *navi = [[LJNavigationViewController alloc] initWithRootViewController:vc];
    [self addChildViewController:navi];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
